package com.chenyi.leetcode.editor.cn;

import java.util.HashSet;
import java.util.Set;

/**
 * [217]存在重复元素
 *
 * @author by chenyi
 * @className ContainsDuplicate
 * @date 2022-08-27 16:09:36
 */
public class ContainsDuplicate {
    public static void main(String[] args) {
        Solution solution = new ContainsDuplicate().new Solution();
        System.out.println(solution.containsDuplicate(new int[]{1}));

    }

    @SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
            //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean containsDuplicate(int[] nums) {
            Set<Integer> set = new HashSet<>();
            for (int num : nums) {
                if (!set.add(num)) {
                    return true;
                }
            }
            return false;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
